<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Linkslistsstyles;
use App\Services\CacheService;
use App\Services\MiniappopenService;
use DB,Log,Exception;

class Linkspath extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'links:path';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '生成一年有效期path';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        // $links_ids = ["dnKiQjAiBbFk3Th","16L484d0se2LHtg","1Mli8I0nL4e5H9g"];
        // foreach ($links_ids as $links_id) {
        //     if (mb_strlen($links_id) <= 16) {
        //         $key = str_pad($links_id,16,"W",STR_PAD_RIGHT);
        //     } else {
        //         $key = substr($links_id,0,16);
        //     }
        //     $timestamp = strtotime("+1 year");
        //     $iv = $timestamp."WLWLWL";
        //     $sign = md5("wl".$iv.$key.$iv."lw");
        //     $path = "pages/index/request?id=".$links_id."&key=".$key."&timestamp=".$timestamp."&nsign=".$sign;
        //     echo "外链ID:".$links_id."\r\n"."小程序路径:".$path."\r\n\r\n";
        // }
        $component_appid = 'wx5cf6f5ec9f891bd7';
        $authorizer_appid = 'wxebe52645b759f9e3';
        $authorizer_refresh_token = 'refreshtoken@@@DeU3GwQhWTN3qdNW-A3pnO-cRZVNRoV-EgTv1RhoNWo';
        $enterprise_name = '北京摩尔企服科技有限公司';
        $code = '91110114MABTWX833B';
        $code_type = 1;
        $legal_persona_wechat = 'wuli6117';
        $legal_persona_name = '武新理';
        $legal_persona_idcard = '411628199303196117';
        $component_phone = '15658606443';
        $data = MiniappopenService::verifyBetaWeApp($component_appid,$authorizer_appid,$authorizer_refresh_token,$enterprise_name,$code,$code_type,$legal_persona_wechat,$legal_persona_name,$legal_persona_idcard,$component_phone);
        Log::info(json_encode($data));
    }
}
